package report;





import java.util.Hashtable;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;





	public class DataSourceJasper implements JRDataSource {  

		private Object[][] data = null;

		private Hashtable tabla = null; // entrada: nombre campo - valor: indice en

		// el arreglo (Integer)

		private int index = -1;

		public DataSourceJasper(Object[][] newData, Hashtable newTabla) {
			data = newData;
			tabla = newTabla;
		}

		/*
		 * (non-Javadoc)
		 * 
		 * @see dori.jasper.engine.JRDataSource#next()
		 */
		public boolean next() throws JRException {		
			index++;
			return (index < data.length);
		}

		/*
		 * (non-Javadoc)
		 * 
		 * @see dori.jasper.engine.JRDataSource#getFieldValue(dori.jasper.engine.JRField)
		 */
		public Object getFieldValue(JRField field) throws JRException {
	 		Object value = null;
			String fieldName = field.getName();
			return data[index][((Integer) tabla.get(fieldName)).intValue()];
		}

}
